<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2014/10/9
 * Time: 11:08
 * 问卷基本信息表
 */
class QuestionBase extends CActiveRecord
{
    public static function model($className=__CLASS__)
    {
        return parent::model($className);
    }

    public function tableName()
    {
        return 'question_base';
    }
	
    const QUESTION_RELEASE = 2; //问卷状态：发布
    const QUESTION_DRAFT = 1;  //问卷状态：草稿
    const QUESTION_DELETE = 0;  //问卷状态：删除
    const QUESTION_COMPLETE = 100;//问卷状态，已完成，即所有网点都完成问卷工作

    /*
     * 获取基本问卷状态
     */
    public static function questionBaseStatus(){
            return array(
                    self::QUESTION_RELEASE =>  '发布',
                    self::QUESTION_DRAFT => '草稿',
                    self::QUESTION_DELETE =>  '删除',
                    self::QUESTION_COMPLETE => '已完成',
            );
    }
	
	const QUESTION_NO_ATTACHMENT = 0; //问卷附件状态：无附件
    const QUESTION_ATTACHMENT = 1;  //问卷附件状态：有附件
    const QUESTION_ATTACHMENT_UPLOADED = 2;  //问卷附件状态：附件正在处理
    const QUESTION_ATTACHMENT_EXECUTED = 3;  //问卷附件状态：附件处理完成

    /*
     * 获取基本问卷状态
     */
    public static function questionAttachmentStatus(){
            return array(
                    self::QUESTION_NO_ATTACHMENT =>  '无附件',
                    self::QUESTION_ATTACHMENT => '有附件',
                    self::QUESTION_ATTACHMENT_UPLOADED => '附件已上传',
                    self::QUESTION_ATTACHMENT_EXECUTED =>  '附件处理完成',
            );
    }
	
    public function getByidentifier($identifier){
        if ($info = $this->find('identifier=:identifier', array(':identifier' => $identifier))){
            return $info->attributes;
        }
        return $info;
    }

    /**
     * 根据网点获得问卷
     */
    public function getByNetwork($network_id){

    }

    /**
     * 根据项目得到问卷
     */
    public function getByProject($project_id){

    }

    /**
     * 拷贝问卷为另一份
     */
    public function copy(){

    }
}